<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Aestate: aestate/ajson/sim/JSON.py Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Aestate
   &#160;<span id="projectnumber">1.0.5</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_374ee6e3281d8312d956f1f155302869.html">aestate</a></li><li class="navelem"><a class="el" href="dir_750b3d80577cce9b9bed1e25acfa02b9.html">ajson</a></li><li class="navelem"><a class="el" href="dir_0ff9c0a1878d33b60c2e08a209ca7aa8.html">sim</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">JSON.py</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_j_s_o_n_8py.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"><a class="line" href="namespaceaestate_1_1ajson_1_1sim_1_1_j_s_o_n.html#a68a53f6deb7372ab413260888869eed1">    1</a></span>&#160;__version__ = <span class="stringliteral">&#39;1.0.0&#39;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno"><a class="line" href="namespaceaestate_1_1ajson_1_1sim_1_1_j_s_o_n.html#aec41d8cf9b23b5aed32bb5adf4a1d148">    2</a></span>&#160;__all__ = [</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;    <span class="stringliteral">&#39;Json&#39;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;]</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160; </div>
<div class="line"><a name="l00006"></a><span class="lineno"><a class="line" href="namespaceaestate_1_1ajson_1_1sim_1_1_j_s_o_n.html#a2c3ec4529ad19dd83fbf854a1fbc18a1">    6</a></span>&#160;__author__ = <span class="stringliteral">&#39;CACode &lt;cacode@163.com&gt;&#39;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; </div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="keyword">from</span> . <span class="keyword">import</span> _default_encoder, JSONEncoder, _default_decoder, JSONDecoder</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="keyword">from</span> decimal <span class="keyword">import</span> Decimal</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160; </div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160; </div>
<div class="line"><a name="l00012"></a><span class="lineno"><a class="line" href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html">   12</a></span>&#160;<span class="keyword">class </span><a class="code" href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html">Json</a>:</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160; </div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    @staticmethod</div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html#a08452b7f5373ba1d1cfe7bd009ba3ef4">   15</a></span>&#160;    <span class="keyword">def </span><a class="code" href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html#a08452b7f5373ba1d1cfe7bd009ba3ef4">dumps</a>(obj, skipkeys=False, ensure_ascii=True, check_circular=True,</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;              allow_nan=True, cls=None, indent=None, separators=None,</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;              encoding=&#39;utf-8&#39;, default=None, use_decimal=True,</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;              namedtuple_as_object=True, tuple_as_array=True,</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;              bigint_as_string=False, sort_keys=False, item_sort_key=None,</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;              for_json=False, ignore_nan=False, int_as_string_bitcount=None,</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;              iterable_as_array=False, **kw):</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        <span class="stringliteral">&quot;&quot;&quot;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="stringliteral">            转json字符串</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="stringliteral">        &quot;&quot;&quot;</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        <span class="keywordflow">if</span> (<span class="keywordflow">not</span> skipkeys <span class="keywordflow">and</span> ensure_ascii <span class="keywordflow">and</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;                check_circular <span class="keywordflow">and</span> allow_nan <span class="keywordflow">and</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;                cls <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> indent <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> separators <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;                encoding == <span class="stringliteral">&#39;utf-8&#39;</span> <span class="keywordflow">and</span> default <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> use_decimal</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;                <span class="keywordflow">and</span> namedtuple_as_object <span class="keywordflow">and</span> tuple_as_array <span class="keywordflow">and</span> <span class="keywordflow">not</span> iterable_as_array</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;                <span class="keywordflow">and</span> <span class="keywordflow">not</span> bigint_as_string <span class="keywordflow">and</span> <span class="keywordflow">not</span> sort_keys</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;                <span class="keywordflow">and</span> <span class="keywordflow">not</span> item_sort_key <span class="keywordflow">and</span> <span class="keywordflow">not</span> for_json</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;                <span class="keywordflow">and</span> <span class="keywordflow">not</span> ignore_nan <span class="keywordflow">and</span> int_as_string_bitcount <span class="keywordflow">is</span> <span class="keywordtype">None</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;                <span class="keywordflow">and</span> <span class="keywordflow">not</span> kw</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        ):</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;            <span class="keywordflow">return</span> _default_encoder.encode(obj)</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        <span class="keywordflow">if</span> cls <span class="keywordflow">is</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;            cls = JSONEncoder</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;        <span class="keywordflow">return</span> cls(</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;            skipkeys=skipkeys, ensure_ascii=ensure_ascii,</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;            check_circular=check_circular, allow_nan=allow_nan, indent=indent,</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;            separators=separators, encoding=encoding, default=default,</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;            use_decimal=use_decimal,</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;            namedtuple_as_object=namedtuple_as_object,</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;            tuple_as_array=tuple_as_array,</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;            iterable_as_array=iterable_as_array,</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;            bigint_as_string=bigint_as_string,</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;            sort_keys=sort_keys,</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;            item_sort_key=item_sort_key,</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;            for_json=for_json,</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;            ignore_nan=ignore_nan,</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;            int_as_string_bitcount=int_as_string_bitcount,</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;            **kw).encode(obj)</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160; </div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    @staticmethod</div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html#abfd3a17d639341453805eaaaeedb039b">   55</a></span>&#160;    <span class="keyword">def </span><a class="code" href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html#abfd3a17d639341453805eaaaeedb039b">loads</a>(s, encoding=None, cls=None, object_hook=None, parse_float=None,</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;              parse_int=None, parse_constant=None, object_pairs_hook=None,</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;              use_decimal=False, **kw):</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="stringliteral">&quot;&quot;&quot;</span></div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;<span class="stringliteral">        json转字典</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<span class="stringliteral">        &quot;&quot;&quot;</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        <span class="keywordflow">if</span> (cls <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> encoding <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> object_hook <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                parse_int <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> parse_float <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span></div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;                parse_constant <span class="keywordflow">is</span> <span class="keywordtype">None</span> <span class="keywordflow">and</span> object_pairs_hook <span class="keywordflow">is</span> <span class="keywordtype">None</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;                <span class="keywordflow">and</span> <span class="keywordflow">not</span> use_decimal <span class="keywordflow">and</span> <span class="keywordflow">not</span> kw):</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            <span class="keywordflow">return</span> _default_decoder.decode(s)</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        <span class="keywordflow">if</span> cls <span class="keywordflow">is</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;            cls = JSONDecoder</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="keywordflow">if</span> object_hook <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;            kw[<span class="stringliteral">&#39;object_hook&#39;</span>] = object_hook</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;        <span class="keywordflow">if</span> object_pairs_hook <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;            kw[<span class="stringliteral">&#39;object_pairs_hook&#39;</span>] = object_pairs_hook</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="keywordflow">if</span> parse_float <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;            kw[<span class="stringliteral">&#39;parse_float&#39;</span>] = parse_float</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;        <span class="keywordflow">if</span> parse_int <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            kw[<span class="stringliteral">&#39;parse_int&#39;</span>] = parse_int</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        <span class="keywordflow">if</span> parse_constant <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;            kw[<span class="stringliteral">&#39;parse_constant&#39;</span>] = parse_constant</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <span class="keywordflow">if</span> use_decimal:</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;            <span class="keywordflow">if</span> parse_float <span class="keywordflow">is</span> <span class="keywordflow">not</span> <span class="keywordtype">None</span>:</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;                <span class="keywordflow">raise</span> TypeError(<span class="stringliteral">&quot;use_decimal=True implies parse_float=Decimal&quot;</span>)</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;            kw[<span class="stringliteral">&#39;parse_float&#39;</span>] = Decimal</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        <span class="keywordflow">return</span> cls(encoding=encoding, **kw).decode(s)</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclassaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json_html_a08452b7f5373ba1d1cfe7bd009ba3ef4"><div class="ttname"><a href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html#a08452b7f5373ba1d1cfe7bd009ba3ef4">aestate.ajson.sim.JSON.Json.dumps</a></div><div class="ttdeci">def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, use_decimal=True, namedtuple_as_object=True, tuple_as_array=True, bigint_as_string=False, sort_keys=False, item_sort_key=None, for_json=False, ignore_nan=False, int_as_string_bitcount=None, iterable_as_array=False, **kw)</div><div class="ttdef"><b>Definition:</b> <a href="_j_s_o_n_8py_source.html#l00015">JSON.py:15</a></div></div>
<div class="ttc" id="aclassaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json_html_abfd3a17d639341453805eaaaeedb039b"><div class="ttname"><a href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html#abfd3a17d639341453805eaaaeedb039b">aestate.ajson.sim.JSON.Json.loads</a></div><div class="ttdeci">def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, use_decimal=False, **kw)</div><div class="ttdef"><b>Definition:</b> <a href="_j_s_o_n_8py_source.html#l00055">JSON.py:55</a></div></div>
<div class="ttc" id="aclassaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json_html"><div class="ttname"><a href="classaestate_1_1ajson_1_1sim_1_1_j_s_o_n_1_1_json.html">aestate.ajson.sim.JSON.Json</a></div><div class="ttdef"><b>Definition:</b> <a href="_j_s_o_n_8py_source.html#l00012">JSON.py:12</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
